package com.shaobufan.museum.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shaobufan.museum.mapper.DepartmentMapper;
import com.shaobufan.museum.pojo.entity.Department;
import com.shaobufan.museum.service.DepartmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 17126
 * @description 针对表【department(部门表)】的数据库操作Service实现
 * @createDate 2024-04-22 12:07:22
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department>
        implements DepartmentService {

    @Resource
    DepartmentMapper departmentMapper;

    /**
     * 添加部门
     *
     * @param departDetail 部门详情
     * @return Boolean
     */
    @Override
    public Boolean addDepartment(String departDetail) {
        Department department = new Department();
        department.setDepartDetail(departDetail);

        departmentMapper.insert(department);

        return true;
    }

    @Override
    public Department searchDepartmentById(Integer departId) {
        QueryWrapper<Department> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("depart_id", departId);
        return departmentMapper.selectOne(queryWrapper);
    }

    @Override
    public List<Department> searchAllDepartment() {
        return departmentMapper.selectList(null);
    }
}